<template>
<<<<<<< HEAD
	<view class="">
		<NavBar title="登录" :isShowLeftBtn="false">
		</NavBar>
	</view>
	<view class="content" :style="{minHeight:contentHeight,backgroundImage:`url(${bgUrl})`}">
		<view class="main">
			<view class="m_t_94 m_b_106">
				<text class="f_36_0_b">
					登录
				</text>
			</view>
			<view class="input_box" style="margin-bottom: 216rpx;">
				<view class="input_item m_b_36">
					<up-input v-model="loginForm.account" placeholder="请输入账号" border="none"
						prefixIcon="/static/images/login/user-alt.png" prefixIconStyle="font-size: 22px;color: #909399"
						fontSize="30rpx"></up-input>
				</view>
				<view class="input_item">
					<up-input v-model="loginForm.password" type="password" placeholder="请输入密码" border="none"
						prefixIcon="/static/images/login/lock.png" prefixIconStyle="font-size: 22px;color: #909399"
						fontSize="30rpx"></up-input>
				</view>
			</view>
			<view class="m_b_16" style="text-align: center;" @click="onJump">
				<text class="f_26_9">
					暂时跳过
				</text>
			</view>
			<view class="submit_btn">
				<up-button throttleTime="1000" @click="onLogin">
					<text class="f_28_f">
						登录
					</text>
				</up-button>
			</view>
		</view>
=======
	<view class="content" :style="{minHeight:contentHeight}">
		<view class="header">
			<view class="" :style="{height:statusBarHeight + 'rpx',width:'750rpx'}">
			</view>

			<view class="" style="display: flex;justify-content: center;margin-top: 216rpx;">
				<up-image :show-loading="true" src="/static/images/my/login_bg.png" width="200rpx" height="200rpx"
					mode="widthFix" shape="circle"></up-image>
			</view>
		</view>

		<view class="main">
			<view class="logoBtn_box">
				<view class="main_btn1 m_t_70 m_b_32">
					<up-button throttleTime="1000" open-type="getPhoneNumber" @getphonenumber="getphonenumber"
						v-if="isAgree">
						<!-- <view class="m_r_6">
							<up-icon name="phone-fill" color="#ffffff" size="22"></up-icon>
						</view> -->
						<view class="">
							<text class="f_28_f">手机号快捷登录</text>
						</view>
					</up-button>
					<up-button throttleTime="1000" v-else @click="tip">
						<!-- <view class="m_r_6">

							<up-icon name="phone-fill" color="#ffffff" size="22"></up-icon>

						</view> -->
						<view class="">
							<text class="f_28_f">手机号快捷登录</text>
						</view>
					</up-button>
				</view>
				<!-- <view class="main_btn2" @click="goto('/pages/index/index')">
					<text class="f_28_9">
						游客模式
					</text>
				</view> -->
			</view>

			<view class="bottom_action">
				<view class="m_b_14" style="text-align: center;padding: 6rpx;" @click="toJump">
					<text class="f_26_9">
						暂时跳过
					</text>
				</view>
				<view class="agree_box">
					<up-checkbox :customStyle="{marginBottom: '6px'}" name="agree" usedAlone v-model:checked="isAgree"
						shape="circle" :size="16" activeColor="#FE5E10" @change="change">
					</up-checkbox>
					<text class="f_26_9 m_b_4">
						登录即代表同意<text class="f_26_9691" style="color: #FE5E10;"
							@click="goto('/pages/my/article?id=23&title=用户协议')">《用户协议》</text>和<text class="f_26_9691"
							style="color: #FE5E10;" @click="goto('/pages/my/article?id=21&title=隐私政策')">《隐私政策》</text>
					</text>
				</view>
			</view>

		</view>
		<up-toast ref="uToastRef"></up-toast>
>>>>>>> 8e38b09233bb4e9930eb2933d0e483ab2018ca5c
	</view>
</template>
<script setup lang="ts">
	import { ref, reactive, getCurrentInstance } from "vue";
<<<<<<< HEAD
	import { onLoad, onShow } from "@dcloudio/uni-app";
	import NavBar from "@/components/navbar.vue"
	import { tabbarStore } from "@/stores/tabbar.js"
	const { proxy } = getCurrentInstance()
	const contentHeight = ref('100vh')
	const statusBarHeight = ref(88)
	const bgUrl = ref('/static/images/login/bg.png')
	const tabbarInfo = tabbarStore()
	const role = ref(0)
	onLoad(() => {
		uni.getSystemInfo({
			success: function (info) {
				statusBarHeight.value = (info.statusBarHeight + 44) * 2
				contentHeight.value = `calc(100vh - ${statusBarHeight.value + 76}rpx)`
			}
		});

		let token = uni.getStorageSync('token')
		role.value = uni.getStorageSync('role')
		console.log(role.value);
		if (token) {
			let arr = []
			let url = ''
			switch (role.value) {
				// 业务员
				case 1:
					arr = tabbarInfo.salesmanTabar
					url = "/pages/salesman/submit"
					break;
				// 业务员主管
				case 2:
					arr = tabbarInfo.salesmanManagerTabbar
					url = "/pages/salesmanManager/waitExamine"
					break;
				// 采购员
				case 3:
					arr = tabbarInfo.purchaserTabbar
					url = "/pages/purchaser/InquiryOrder"
					break;
				// 采购员主管
				case 4:
					arr = tabbarInfo.purchaserManagerTabbar
					url = "/pages/purchaserManager/message"
					break;
				// 财务
				case 5:
					arr = tabbarInfo.financeTabbar
					url = "/pages/finance/waitPayment"
					break;
				default:
					arr = tabbarInfo.salesmanTabar
					url = "/pages/salesman/submit"
					break;
			}
			tabbarInfo.curList = arr
			uni.reLaunch({
				url: url
			})
		}
	})
	const loginForm = ref({
		account: '',
		password: ''
	})
	const onLogin = async () => {
		let res = await proxy.$http('login.login', { ...loginForm.value })
		if (res.code == 1) {
			// getUserInfo()
			role.value = res.data.userinfo.group_id
			uni.setStorageSync('token', res.data.userinfo.token)
			uni.setStorageSync('role', res.data.userinfo.group_id)
			initRole(res.data)
		}
	}
	const initRole = (e) => {
		let arr = []
		let url = ''
		switch (role.value) {
			case 1:
				arr = tabbarInfo.salesmanTabar
				url = "/pages/salesman/submit"
				break;
			// 业务员主管
			case 2:
				arr = tabbarInfo.salesmanManagerTabbar
				url = "/pages/salesmanManager/waitExamine"
				break;
			// 采购员
			case 3:
				arr = tabbarInfo.purchaserTabbar
				url = "/pages/purchaser/InquiryOrder"
				break;
			// 采购员主管
			case 4:
				arr = tabbarInfo.purchaserManagerTabbar
				url = "/pages/purchaserManager/message"
				break;
			// 财务
			case 5:
				arr = tabbarInfo.financeTabbar
				url = "/pages/finance/waitPayment"
				break;
			default:
				arr = tabbarInfo.salesmanTabar
				url = "/pages/salesman/submit"
				break;
		}
		tabbarInfo.curList = arr
		uni.$u.toast('登录成功')
		setTimeout(() => {
			uni.reLaunch({
				url: url
			})
		}, 800)
	}
	const onJump = () => {
		let arr = []
		let url = ''
		arr = tabbarInfo.salesmanTabar
		url = "/pages/salesman/submit"
		tabbarInfo.curList = arr
		setTimeout(() => {
			uni.reLaunch({
				url: url
			})
		}, 800)
	}
	// const getUserInfo = async () => {
	// 	let res = await proxy.$http('common.getUserInfo')
	// 	if (res.code == 1) {
	// 	}
	// }
</script>
<style lang="scss" scoped>
	.content {
		// background: #F7F8FC;
		padding: 20rpx;
		padding-bottom: 64rpx;
		background-size: 100% 70%;
		background-repeat: no-repeat;

		.main {
			text-align: center;
			width: 710rpx;

			.input_box {
				.input_item {
					width: 652rpx;
					height: 92rpx;
					padding: 0 30rpx;
					background: #FFFFFF;
					box-shadow: 2rpx 6rpx 5rpx 0rpx rgba(197, 197, 197, 0.29);
					border-radius: 10rpx;
					border: 1px solid #EDEDEE;
					display: flex;
					align-items: center;
				}
			}


		}
=======
	import { onLoad, onShow, onReady } from "@dcloudio/uni-app";
	// import QQMapWX from '@/common/qqmap-wx-jssdk.js'
	import NavBar from "@/components/navbar.vue"
	const { proxy } = getCurrentInstance()
	const contentHeight = ref('100vh')
	const statusBarHeight = ref(88)
	const uToastRef = ref(null)
	const goto = (url) => {
		proxy.$gloab.gotoPage(url)
	}

	onLoad((e) => {
		uni.getSystemInfo({
			success: function (info) {
				statusBarHeight.value = (info.statusBarHeight) * 2
				// contentHeight.value = `calc(100vh - ${statusBarHeight.value + 90}rpx)`
			}
		});
		if (e.yinigixao_user_id) {
			yinigixao_user_id.value = e.yinigixao_user_id
		}

		if (e.invite_parent_id) {
			invite_parent_id.value = e.invite_parent_id
		}
		if (uni.getStorageSync('yinigixao_user_id')) {
			yinigixao_user_id.value = uni.getStorageSync('yinigixao_user_id').yinigixao_user_id
		}
		if (uni.getStorageSync('invite_parent_id')) {
			invite_parent_id.value = uni.getStorageSync('invite_parent_id').invite_parent_id
		}
	})
	onShow(() => {
		if (uni.getStorageSync('token')) {
			// uni.removeStorageSync('token')
			if (yinigixao_user_id.value) {
				uni.setStorageSync('yinigixao_user_id', { yinigixao_user_id: yinigixao_user_id.value })
			}
			if (invite_parent_id.value) {
				uni.setStorageSync('invite_parent_id', { invite_parent_id: invite_parent_id.value })
			}
			uni.reLaunch({
				url: "/pages/index/index"
			})
		}
	})
	const yinigixao_user_id = ref(0)
	const invite_parent_id = ref(0)
	const change = (e) => {
		isAgree.value = e
	}
	const isAgree = ref(false)
	const tip = () => {
		if (!isAgree.value) {
			uni.showToast({
				title: "请先勾选协议",
				icon: "none"
			})
			return
		}
	}
	// 授权登录
	const phoneRes = ref()
	const codeRES = ref()
	const getphonenumber = (e) => {
		if (e.detail.code) {
			uni.login({
				success: async (res) => {
					phoneRes.value = e
					codeRES.value = res
					login()
				}
			})
		}

	}
	const login = () => {
		uni.showLoading({
			title: "登录中，请稍后...",
			mask: true
		})
		proxy.$http('login.wxlLogin', {
			code: codeRES.value.code,
			encryptedData: phoneRes.value.detail.encryptedData,
			iv: phoneRes.value.detail.iv,
			invite_parent_id: invite_parent_id.value,
			yinigixao_user_id: yinigixao_user_id.value
		}).then(async (res) => {
			uni.hideLoading()
			if (res.code == 1) {
				uni.setStorageSync('token', res.data.userinfo.token)
				// let res2 = await proxy.$http('my.getUserInfo')
				// let data = res2.data
				// 0普通用户 1集团用户
				// uni.setStorageSync('roleInfo', { role: 0 })
				uni.showToast({
					title: "登录成功",
					icon: 'success',
					mask: true
				})
				setTimeout(() => {
					uni.navigateTo({
						url: "/pages/index/index"
					})
				}, 800)
				// proxy.$http('my.getUserInfo',).then(res => {
				// 	setTimeout(() => {
				// 		uni.hideLoading()
				// 		// // 判断是否有昵称头像
				// 		if (!res.data.avatar) {
				// 			uni.redirectTo({
				// 				url: "/pages/login/setAvatar"
				// 			})
				// 		} else if (!res.data.nickname) {
				// 			uni.redirectTo({
				// 				url: "/pages/login/setNickname"
				// 			})
				// 		} else {
				// 			uni.navigateTo({
				// 				url: "/pages/index/index"
				// 			})
				// 		}

				// 	}, 800)
				// })

			} else {
				uToastRef.value.show({
					message: res.msg
				})

			}
		});
	}
	// // 区县相关
	// const qqmapsdk = ref(null)
	// onReady(() => {
	// 	qqmapsdk.value = new QQMapWX({
	// 		key: proxy.$config.txMapKey
	// 	});
	// 	getLoaction()
	// })
	// const longitude = ref()
	// const latitude = ref()
	// const positionInfo = ref({
	// 	province_name: '',
	// 	city_name: '',
	// 	area_name: ''

	// })
	// const getLoaction = () => {
	// 	uni.getLocation({
	// 		type: 'gcj02', // 返回可以用于uni.openLocation的经纬度
	// 		success: function (res) {
	// 			longitude.value = res.longitude
	// 			latitude.value = res.latitude
	// 			qqmapsdk.value.reverseGeocoder({
	// 				location: {
	// 					latitude: res.latitude,
	// 					longitude: res.longitude
	// 				},
	// 				success: (res2) => {
	// 					console.log(res2);
	// 					// let data = res2.result.address_component
	// 					// curAddress.value = res2.result.formatted_addresses.standard_address
	// 					// console.log(data);
	// 					// getDistrictByCityId(res2)
	// 					// 获取区id
	// 					positionInfo.value.province_name = res2.result.address_component.province
	// 					positionInfo.value.city_name = res2.result.address_component.city
	// 					positionInfo.value.area_name = res2.result.address_component.district
	// 				},
	// 				fail: (e) => {
	// 					console.log(e, 'eee')
	// 				}
	// 			})

	// 			// 获取附近房屋
	// 		},
	// 		fail: function (e) {
	// 			// uni.setStorageSync('position_info', { code: 2, longitude: 0, latitude: 0 })
	// 			console.log('获取位置信息失败：' + JSON.stringify(e));
	// 		}
	// 	});
	// }
	const toJump = () => {
		uni.reLaunch({
			url: "/pages/index/index"
		})
	}
</script>
<style lang="scss" scoped>
	.content {
		background: #FFFFFF;

		.header {
			width: 750rpx;
			height: 628rpx;

			.nav {
				height: 90rpx;
				display: flex;
				align-items: center;
				justify-content: center;
			}
		}

		.header_bg {
			position: absolute;
			top: 0;
			left: 0;
		}

		.main {
			position: relative;
			height: calc(100vh - 628rpx);

			.logoBtn_box {
				display: flex;
				flex-direction: column;
				align-items: center;

				.main_btn1 {
					::v-deep.u-button {
						width: 690rpx !important;
						height: 94rpx !important;
						background: #FE5E10 !important;
						border-radius: 10rpx !important;
					}

				}

				.main_btn2 {
					width: 690rpx !important;
					height: 94rpx !important;
					opacity: 0.8;
					border: 2rpx solid #707070;
					border-radius: 10rpx !important;
					display: flex;
					align-items: center;
					justify-content: center;
				}


			}

			.bottom_action {
				position: absolute;
				width: 750rpx;
				bottom: calc(222rpx + env(safe-area-inset-bottom));
			}

			.agree_box {
				display: flex;
				justify-content: center;
				align-items: center;
			}
		}

>>>>>>> 8e38b09233bb4e9930eb2933d0e483ab2018ca5c
	}
</style>